<template>
	<view class="content">

		<u-sticky>
			<view class="u-flex u-row-between " style="background: #fff;padding: 20rpx 30rpx;">
				<check type="效果图" @select="select">
					<image slot="image" src="/static/check1.png" style="width: 40rpx;height: 40rpx;"></image>
				</check>
				<search :noticeList="HotList" :keyword="initial.parm.keyword" @Search="search"> </search>
			</view>
			<dropdown ref="dropdown" @updata="getupdata" v-if="show" :nav='navList'></dropdown>
		</u-sticky>

		<waterfall :list="list" v-if="list.length" @go="go" @poup="poup"> </waterfall>



		<u-loadmore :status="initial.status" />


		<removeWater ref="chilren" @remove="remove" :goodId='poupInfo.id'></removeWater>


		<backTop></backTop>


		<u-action-sheet :list="poupList" v-model="poupShow" @click="poupSure"></u-action-sheet>
	</view>
</template>

<script>
	import dropdown from "../../components/dropdown.vue";
	import loader from '@/common/loadPage.js';
	import search from "../../components/search";
	import check from "../../components/check";
	import removeWater from '@/components/removeWater';
	import backTop from '../../components/backTop';
	import {
		Class
	} from '@/untils/common.js';
	import waterfall from '../../components/waterfall'

	export default {
		components: {
			dropdown,
			search,
			waterfall,
			check,
			removeWater,
			backTop,
		},
		mixins: [loader],
		data() {
			return {
				list: [],
				initial: {
					geturl: "/index/cases",
					parm: {
						type: '',
						case_type: "",
						cate: {},
						keyword: "",
					},

					isPage: true
				},
				show: false,
				poupInfo: '',
				poupList: [{
					text: '观看全景'
				}, {
					text: '去除水印'
				}],
				poupShow: false,
				navList:[]
			}
		},
		async onLoad(options) {
			if (options.keyword) {
				this.initial.parm.keyword = options.keyword
			}
			if (options.id) {
				if (options.id == "效果图") {
					this.initial.parm.type = 1;
					uni.setNavigationBarTitle({
						title: options.id
					})
				} else {
					this.initial.parm.type = 2;
					uni.setNavigationBarTitle({
						title: options.id
					})
				}

			} else {
				uni.setNavigationBarTitle({
					title: "效果图&全景漫游"
				})
			}
			this.getGoods()

		},

		methods: {
			remove() {
				this.initial.page = 1;
				this.list = []; //清空list防止重付
				this.getGoods()
				this.$refs.chilren.show = false
			},

			poupSure(e) {

				if (!e) {
					uni.navigateTo({
						url: '/pages/web/index?url=' + this.poupInfo.url
					})
				} else {
					this.poupShow = false;
					this.$refs.chilren.show = true;
				}

			},
			poup(e) {

				if (e.vip) {
					uni.navigateTo({
						url: '/pages/web/index?url=' + e.url
					})
				} else {

					this.poupInfo = e;
					this.poupShow = true;
				}


			},
			go(item) {
				console.log(111)
				uni.navigateTo({
					url: '/else/designSketch/detail?id=' + item.id
				})
			},
			// 搜索

			search(e) {
				this.initial.parm.keyword = e;
				this.initial.page = 1;
				this.list = []; //清空list防止重付
				this.getGoods()
			},

			// 分类选择
			select(e) {
				this.initial.page = 1;
				this.list = []; //清空list防止重付
				this.initial.parm.case_type = e.type;
				this.show = true;
				this.getGoods()
				this.getCaseCate(e.type)

			},
			// 分类案例列表
			getCaseCate(parent_id) {
				Class("/index/caseCate", parent_id).then(res => {
				     this.$refs.dropdown.navChange(res);
				})
			},
			getupdata(e) {

				var obj1 = this.$refs.dropdown.nav;
				var Obj = {};
				obj1.map(item => {
					if (item.obj) {
						Obj[item.enName] = item.obj.id
					}
				})
				this.initial.page = 1;
				this.list = []; //清空list防止重付
				this.initial.parm.cate = Obj;
				this.getGoods()
			}


		}
	}
</script>

<style scoped>
	page {
		background: #F8F8F8;
	}

	.list {
		background: #FFFFFF;
		width: 336rpx;
		margin-bottom: 20rpx;
	}
</style>
